﻿using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using ElectronicWMSA.Comm.ClassFiles;

namespace ElectronicWMSA.Warehouse
{
    public partial class List_PickingFrm : Form
    {
        private string strWhere = "";
        public List_PickingFrm()
        {
            InitializeComponent();
            this.page1.PageCurrent = 1;
            this.page1.PageSize = 3000;
            this.page1.Bind();
            label1.Text = DateTime.Now.ToString("yyyy-MM-dd") + "拣货进度展示";
        }
        private int DBindData()
        {
            ElectronicWMSA.Comm.Forms.MsControls.PageData pageData = new ElectronicWMSA.Comm.Forms.MsControls.PageData();
            pageData.TableName = "PD_PickingShowList";
            pageData.PrimaryKey = "NID";
            pageData.OrderStr = "NID";
            pageData.PageIndex = this.page1.PageCurrent;
            pageData.PageSize = this.page1.PageSize;
            pageData.QueryCondition = strWhere;
            pageData.QueryFieldName = "*";

            this.page1.bindingSource.DataSource = pageData.QueryDataTable().Tables[0];
            this.page1.bindingNavigator.BindingSource = page1.bindingSource;
            this.rowMergeView1.AutoGenerateColumns = false;
            this.rowMergeView1.DataSource = this.page1.bindingSource;
            this.rowMergeView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            this.rowMergeView1.MergeColumnNames.Add("PickNO1");
            this.rowMergeView1.MergeColumnNames.Add("P11");
            this.rowMergeView1.MergeColumnNames.Add("P14");
            this.rowMergeView1.MergeColumnNames.Add("P13");
            this.rowMergeView1.MergeColumnNames.Add("P15");
            this.rowMergeView1.MergeColumnNames.Add("P16");

            SystemVariable.DataGridViewStyle(rowMergeView1);
            this.rowMergeView1.CurrentCell = null;
            this.rowMergeView1.ClearSelection();

            return pageData.TotalCount;
        }
        private int page1_EventPaging(Comm.Forms.MsControls.EventPagingArg e)
        {
            return DBindData();
        }

        private string PickNo = "";
        private void btnUserSearch_Click(object sender, EventArgs e)
        {
            //strWhere = "";
            //if (this.txtPickingNuber.Text.Trim() != "")
            //{
            //    PickNo = this.txtPickingNuber.Text.Trim();
            //    strWhere = " PickNO='" + PickNo + "' ";
            //}
            this.page1.Bind();
        }

        private void progressBar1_Click(object sender, EventArgs e)
        {
            List_PickingNOFrm frm = new List_PickingNOFrm();
            frm.ShowDialog();
            PickNo = frm.PickingNO;
            // this.txtPickingNuber.Text = PickNo;
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void rowMergeView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            if (rowMergeView1.RowCount > 0)
            {
                this.rowMergeView1.Rows[0].Cells[6].Style.BackColor = System.Drawing.Color.Yellow;
                this.rowMergeView1.Rows[1].Cells[6].Style.BackColor = System.Drawing.Color.Yellow;

                this.rowMergeView1.Rows[2].Cells[6].Style.BackColor = System.Drawing.Color.Yellow;
                this.rowMergeView1.Rows[3].Cells[6].Style.BackColor = System.Drawing.Color.Yellow;

                this.rowMergeView1.Rows[4].Cells[6].Style.BackColor = System.Drawing.Color.Green;
                this.rowMergeView1.Rows[5].Cells[6].Style.BackColor = System.Drawing.Color.Green;

                this.rowMergeView1.Rows[6].Cells[6].Style.BackColor = System.Drawing.Color.Yellow;
                this.rowMergeView1.Rows[7].Cells[6].Style.BackColor = System.Drawing.Color.Yellow;

                this.rowMergeView1.Rows[8].Cells[6].Style.BackColor = System.Drawing.Color.Red;
                this.rowMergeView1.Rows[9].Cells[6].Style.BackColor = System.Drawing.Color.Red;

                this.rowMergeView1.Rows[10].Cells[6].Style.BackColor = System.Drawing.Color.Yellow;
                this.rowMergeView1.Rows[11].Cells[6].Style.BackColor = System.Drawing.Color.Yellow;

                this.rowMergeView1.Rows[12].Cells[6].Style.BackColor = System.Drawing.Color.Green;
                this.rowMergeView1.Rows[13].Cells[6].Style.BackColor = System.Drawing.Color.Green;
                for (int i = 0; i < rowMergeView1.Rows.Count; i++)
                {
                    for (int col = 0; col < rowMergeView1.Columns.Count; col++)
                    {
                        rowMergeView1.Rows[i].Cells[col].Style.Font = new Font("微软雅黑", 16, FontStyle.Bold, GraphicsUnit.Pixel);
                    }
                }
            }
        }

    }
}
